/**
 * 
 */
package com.liusoft.android.fmagic;

import android.graphics.Rect;

/**
 * 用于计算各种尺寸的类
 * @author Winter Lau
 */
public class MagicSizer {
	
	public final static int BORDER_SIZE = 10;	//边框宽度
	public final static int IMG_GAP_SIZE = 2;	//图片间隔
	
	private final Rect rect_board;
	private final Rect rect_img;
	private final int[] piece_size;
	private int rowCount;
	private int colCount;

	/**
	 * 初始化游戏的面板大小
	 * @param r		游戏面板框
	 * @param row	图片切分的行数
	 * @param col	图片切分的列数
	 */
	public MagicSizer(Rect r, int row, int col) {
		this.rowCount = row;
		this.colCount = col;
		this.rect_board = r;
		//计算图片大小以及缝隙大小
		this.rect_img = new Rect(BORDER_SIZE,BORDER_SIZE,
				r.width()-BORDER_SIZE,
				r.height()-BORDER_SIZE
		);
		int width = r.width() - 2 * BORDER_SIZE;
		int height = r.height() - 2 * BORDER_SIZE;
		this.piece_size = new int[]{width / colCount, height / rowCount};		
	}
	
	/**
	 * 返回图片切分的行数
	 * @return
	 */
	public int getRowCount() {
		return rowCount;
	}
	
	/**
	 * 返回图片切分的列数
	 * @return
	 */
	public int getColCount() {
		return colCount;
	}
	
	/**
	 * 返回游戏方盘的大小
	 * @return
	 */
	public Rect GetBoardRect() {
		return this.rect_board;
	}
	
	/**
	 * 返回魔盘图片显示的大小
	 * @return
	 */
	public Rect GetImageRect() {
		return this.rect_img;
	}
	
	/**
	 * 返回每小块图片的大小
	 * @return
	 */
	public int[] GetPieceSize() {
		return this.piece_size;
	}
	
}
